﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Algorithms
{
    /// <summary>
    /// 
    /// </summary>
    public class MedianOfTwoSortedArrays
    {
        public static double Action1(int[] nums1, int[] nums2)
        {
            List<int> t = new List<int>();
            t.AddRange(nums1);
            t.AddRange(nums2);
            t.Sort();
              int half = t.Count / 2;
            if (t.Count % 2 == 0)
            {
              
                return (t[half] + t[half - 1]) / 2.00;
            }
            else
            {
                return t[half];
            }
        }

        public static double Action2(int[] nums1, int[] nums2)
        {
            List<int> t = new List<int>();
            t.AddRange(nums1);
            t.AddRange(nums2);
            for(int i = 0; i < t.Count; i++)
            {
                for(int j = 0; j < t.Count; j++)
                {
                    if (t[i] > t[j])
                    {
                        var a = t[i];
                        t[i] = t[j];
                        t[j] = a;
                    }
                }
            }

            int half = t.Count / 2;
            if (t.Count % 2 == 0)
            {

                return (t[half] + t[half - 1]) / 2.00;
            }
            else
            {
                return t[half];
            }
        }
    }
}
